var vm = new Vue({
    el: '#app',
    data: {
        host: host,
        user_id: sessionStorage.user_id || localStorage.user_id,
        token: sessionStorage.token || localStorage.token,
        username: sessionStorage.username || localStorage.username,


        password: '',
        new_pwd: '',
        repeat_pwd: '',


    },

    methods: {
        // 退出
        logout: function(){
            sessionStorage.clear();
            localStorage.clear();
            location.href = '/login.html';
        },
        submit: function(){
            // 修改密码
            var formData = new FormData(event.target);
            console.log(this.old_pwd);
            console.log(this.new_pwd);
            console.log(this.repeat_pwd);
            console.log(this.token);

            axios.put(this.host + '/password/',
                {
                "password":this.password,
                "new_pwd":this.new_pwd,
                "repeat_pwd":this.repeat_pwd,
                },
                {
                headers: {
                    'Authorization': 'JWT ' + this.token
                },
                responseType: 'json'
            })
            .then(response => {
                // 将新地址添加大数组头部
                console.log(this.new_pwd);
                location.href = '/user_center_site.html?next=/user_center_pass.html';
            })
            .catch(error => {
                console.log(error.response.data);
            })

        },


    }
})